var proxy = require('http-proxy').createProxyServer({});
proxy.on(function (err, req, res) { res.writeHead(500, { 'Content-Type': "text/plain" }); });
var server = require('http').createServer(function (req, res) {
    var host = req.headers.host;
    switch (host) {
        case 'yangwl.com':
            proxy.web(req, res, { target: 'http://127.0.0.1:3000' });
            break;
        case 'www.yangwl.com':
            proxy.web(req, res, { target: 'http://127.0.0.1:3000' });
            break;
        case 'hien.yangwl.com':
            proxy.web(req, res, { target: 'http://127.0.0.1:3001' });
            break;
        default:
            res.writeHead(200, { 'Content-Type': 'text/plain' });
            res.end('Welcome to my server!');
    }
});
server.listen(80);
console.log('listen 80');